package com.designpattern.behavior.iterator;

import java.util.List;

/**
 * @author Administration
 * @date 2021/10/27 - 11:05 - 星期三
 * @project 行为型模式中的迭代器模式  具体迭代器（Iterator）角色
 * @package com.designpattern.behavior.iterator
 * @by 晨
 */
public class StudentIteratorImpl implements StudentIterator{

    private List<Student> list;

    private Integer position = 0;

    public StudentIteratorImpl(List<Student> list) {
        this.list = list;
    }

    @Override
    public boolean hastNext() {
        return position < list.size();
    }

    @Override
    public Student next() {
        Student student = list.get(position);
        position++;
        return student;
    }
}
